package com.gamerole.opencv;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Switch;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageView imageView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView = findViewById(R.id.imageView);
        findViewById(R.id.yuantu).setOnClickListener(this);
        findViewById(R.id.mohu_blur).setOnClickListener(this);
        findViewById(R.id.mohu_gaosi).setOnClickListener(this);
        findViewById(R.id.mohu_blur_gaosi_shuangbian).setOnClickListener(this);
        findViewById(R.id.kernel).setOnClickListener(this);
        findViewById(R.id.bianyuan).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.test);
        switch (v.getId()) {
            case R.id.yuantu:
                break;
            case R.id.mohu_blur:
                blur(bitmap);
                break;
            case R.id.mohu_gaosi:
                blurGaosi(bitmap);
                break;
            case R.id.mohu_blur_gaosi_shuangbian:
                blurGaosiShuangbian(bitmap);
                break;
            case R.id.kernel:
                kernel(bitmap);
                break;
            case R.id.bianyuan:
                bianyuan(bitmap);
                break;
        }
        imageView.setImageBitmap(bitmap);
    }

    static {//加载so库
        System.loadLibrary("native-lib");
    }

    //获得Canny边缘
    native void getEdge(Object bitmap);

    native void blur(Object bitmap);

    native void blurGaosi(Object bitmap);

    native void blurGaosiShuangbian(Object bitmap);

    native void kernel(Object bitmap);
    native void bianyuan(Object bitmap);


}